import { request } from '@/utils/request';
/**
 * @description 获取流程列表
 * @returns
 */
export function getFlowList(data) {
  return request({
    url: '/api/deployment/getDeployment',
    method: 'post',
    data,
  });
}

/**
 * @description 删除流程
 * @returns
 */
export function deleteFlow(id) {
  return request(
    {
      url: `/api/deployment/delDefinition?proc_key=${id}`,
      method: 'get',
    },
    {
      successMsg: '删除成功',
    },
  );
}

/**
 * @description 创建流程
 * @returns
 */
export function createFlow(data) {
  return request({
    url: '/api/Flow/addFlow',
    method: 'post',
    data,
  });
}

// 增加流程
export function editFlow(data) {
  return request({
    url: '/api/Flow/editFlow',
    method: 'post',
    data,
  });
}

// 获取常用流程信息

export function getCommonFlowList() {
  return request({
    url: '/api/deployment/getSatrtPageData',
    method: 'get',
  });
}

// 获取流程定义xml
export function deploymentXML(data) {
  return request({
    url: '/api/deployment/getDeploymentXmlById',
    method: 'get',
    params: data,
  });
}

// 获取指定流程下的节点集合
export function getTaskListWithProcessKey(data) {
  return request({
    url: '/api/deployment/getTaskListWithProcessKey',
    method: 'get',
    params: data,
  });
}

// 获取指定流程下的连线集合（有方向条件的）
export function getConnectionListByProcessKey(data) {
  return request({
    url: '/api/deployment/getConnectionListByProcessKey',
    method: 'get',
    params: data,
  });
}
// 获取指定流程下的网关集合
export function getGateWayListByProcDefKey(data) {
  return request({
    url: '/api/deployment/getGateWayListByProcDefKey',
    method: 'get',
    params: data,
  });
}
//获取指定流程下的业务方法集合
export function getBusinessMethodListByProcessDefinitionId(data) {
  return request({
    url: '/api/deployment/getBusinessMethodListByProcessDefinitionId',
    method: 'get',
    params: data,
  });
}
// 流程发布
export function deployWithBPMNJS(data) {
  return request({
    url: '/api/deployment/deployWithBPMNJS',
    method: 'post',
    data,
  });
}
// 设置流程发起权限
export function setFlowStartPower(data) {
  return request({
    url: '/api/deployment/setFlowStartPower',
    method: 'post',
    data,
  });
}
//流程仿真
export function runProcSimulation(data) {
  return request({
    url: '/api/task/runProcSimulation',
    method: 'post',
    data,
  },
  { timeout: 0 });
}

// 获取流程表单JSON的方法
export function getFormJSON(data) {
  return request({
    url: '/api/task/getHisFormJson',
    method: 'post',
    data,
  });
}

// 获取流程待办列表
export function getTodoList(queryParams) {
  return request({
    url: '/api/task/getTodoList',
    method: 'get',
    params: queryParams
  });
}

// 获取流程待办列表
export function getTodoListByUserId(queryParams) {
  return request({
    url: '/api/task/getTodoList',
    method: 'get',
    params: queryParams
  });
}

//流程监控接口  --------
//在办列表
export function getOnTheWayFlowList(queryParams) {
  return request({
    url: '/api/task/getOnTheWayFlowList',
    method: 'get',
    params: queryParams
  });
}